/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
/**
 * Autogenerated by Thrift Compiler (0.15.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.apache.accumulo.core.dataImpl.thrift;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
public class MultiScanResult implements org.apache.thrift.TBase<MultiScanResult, MultiScanResult._Fields>, java.io.Serializable, Cloneable, Comparable<MultiScanResult> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("MultiScanResult");

  private static final org.apache.thrift.protocol.TField RESULTS_FIELD_DESC = new org.apache.thrift.protocol.TField("results", org.apache.thrift.protocol.TType.LIST, (short)1);
  private static final org.apache.thrift.protocol.TField FAILURES_FIELD_DESC = new org.apache.thrift.protocol.TField("failures", org.apache.thrift.protocol.TType.MAP, (short)2);
  private static final org.apache.thrift.protocol.TField FULL_SCANS_FIELD_DESC = new org.apache.thrift.protocol.TField("fullScans", org.apache.thrift.protocol.TType.LIST, (short)3);
  private static final org.apache.thrift.protocol.TField PART_SCAN_FIELD_DESC = new org.apache.thrift.protocol.TField("partScan", org.apache.thrift.protocol.TType.STRUCT, (short)4);
  private static final org.apache.thrift.protocol.TField PART_NEXT_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("partNextKey", org.apache.thrift.protocol.TType.STRUCT, (short)5);
  private static final org.apache.thrift.protocol.TField PART_NEXT_KEY_INCLUSIVE_FIELD_DESC = new org.apache.thrift.protocol.TField("partNextKeyInclusive", org.apache.thrift.protocol.TType.BOOL, (short)6);
  private static final org.apache.thrift.protocol.TField MORE_FIELD_DESC = new org.apache.thrift.protocol.TField("more", org.apache.thrift.protocol.TType.BOOL, (short)7);

  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new MultiScanResultStandardSchemeFactory();
  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new MultiScanResultTupleSchemeFactory();

  public @org.apache.thrift.annotation.Nullable java.util.List<TKeyValue> results; // required
  public @org.apache.thrift.annotation.Nullable java.util.Map<TKeyExtent,java.util.List<TRange>> failures; // required
  public @org.apache.thrift.annotation.Nullable java.util.List<TKeyExtent> fullScans; // required
  public @org.apache.thrift.annotation.Nullable TKeyExtent partScan; // required
  public @org.apache.thrift.annotation.Nullable TKey partNextKey; // required
  public boolean partNextKeyInclusive; // required
  public boolean more; // required

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    RESULTS((short)1, "results"),
    FAILURES((short)2, "failures"),
    FULL_SCANS((short)3, "fullScans"),
    PART_SCAN((short)4, "partScan"),
    PART_NEXT_KEY((short)5, "partNextKey"),
    PART_NEXT_KEY_INCLUSIVE((short)6, "partNextKeyInclusive"),
    MORE((short)7, "more");

    private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

    static {
      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // RESULTS
          return RESULTS;
        case 2: // FAILURES
          return FAILURES;
        case 3: // FULL_SCANS
          return FULL_SCANS;
        case 4: // PART_SCAN
          return PART_SCAN;
        case 5: // PART_NEXT_KEY
          return PART_NEXT_KEY;
        case 6: // PART_NEXT_KEY_INCLUSIVE
          return PART_NEXT_KEY_INCLUSIVE;
        case 7: // MORE
          return MORE;
        default:
          return null;
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByName(java.lang.String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final java.lang.String _fieldName;

    _Fields(short thriftId, java.lang.String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public java.lang.String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __PARTNEXTKEYINCLUSIVE_ISSET_ID = 0;
  private static final int __MORE_ISSET_ID = 1;
  private byte __isset_bitfield = 0;
  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.RESULTS, new org.apache.thrift.meta_data.FieldMetaData("results", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TKeyValue.class))));
    tmpMap.put(_Fields.FAILURES, new org.apache.thrift.meta_data.FieldMetaData("failures", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.MAP        , "ScanBatch")));
    tmpMap.put(_Fields.FULL_SCANS, new org.apache.thrift.meta_data.FieldMetaData("fullScans", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TKeyExtent.class))));
    tmpMap.put(_Fields.PART_SCAN, new org.apache.thrift.meta_data.FieldMetaData("partScan", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TKeyExtent.class)));
    tmpMap.put(_Fields.PART_NEXT_KEY, new org.apache.thrift.meta_data.FieldMetaData("partNextKey", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TKey.class)));
    tmpMap.put(_Fields.PART_NEXT_KEY_INCLUSIVE, new org.apache.thrift.meta_data.FieldMetaData("partNextKeyInclusive", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.MORE, new org.apache.thrift.meta_data.FieldMetaData("more", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(MultiScanResult.class, metaDataMap);
  }

  public MultiScanResult() {
  }

  public MultiScanResult(
    java.util.List<TKeyValue> results,
    java.util.Map<TKeyExtent,java.util.List<TRange>> failures,
    java.util.List<TKeyExtent> fullScans,
    TKeyExtent partScan,
    TKey partNextKey,
    boolean partNextKeyInclusive,
    boolean more)
  {
    this();
    this.results = results;
    this.failures = failures;
    this.fullScans = fullScans;
    this.partScan = partScan;
    this.partNextKey = partNextKey;
    this.partNextKeyInclusive = partNextKeyInclusive;
    setPartNextKeyInclusiveIsSet(true);
    this.more = more;
    setMoreIsSet(true);
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public MultiScanResult(MultiScanResult other) {
    __isset_bitfield = other.__isset_bitfield;
    if (other.isSetResults()) {
      java.util.List<TKeyValue> __this__results = new java.util.ArrayList<TKeyValue>(other.results.size());
      for (TKeyValue other_element : other.results) {
        __this__results.add(new TKeyValue(other_element));
      }
      this.results = __this__results;
    }
    if (other.isSetFailures()) {
      java.util.Map<TKeyExtent,java.util.List<TRange>> __this__failures = new java.util.HashMap<TKeyExtent,java.util.List<TRange>>(other.failures.size());
      for (java.util.Map.Entry<TKeyExtent, java.util.List<TRange>> other_element : other.failures.entrySet()) {

        TKeyExtent other_element_key = other_element.getKey();
        java.util.List<TRange> other_element_value = other_element.getValue();

        TKeyExtent __this__failures_copy_key = new TKeyExtent(other_element_key);

        java.util.List<TRange> __this__failures_copy_value = new java.util.ArrayList<TRange>(other_element_value.size());
        for (TRange other_element_value_element : other_element_value) {
          __this__failures_copy_value.add(new TRange(other_element_value_element));
        }

        __this__failures.put(__this__failures_copy_key, __this__failures_copy_value);
      }
      this.failures = __this__failures;
    }
    if (other.isSetFullScans()) {
      java.util.List<TKeyExtent> __this__fullScans = new java.util.ArrayList<TKeyExtent>(other.fullScans.size());
      for (TKeyExtent other_element : other.fullScans) {
        __this__fullScans.add(new TKeyExtent(other_element));
      }
      this.fullScans = __this__fullScans;
    }
    if (other.isSetPartScan()) {
      this.partScan = new TKeyExtent(other.partScan);
    }
    if (other.isSetPartNextKey()) {
      this.partNextKey = new TKey(other.partNextKey);
    }
    this.partNextKeyInclusive = other.partNextKeyInclusive;
    this.more = other.more;
  }

  public MultiScanResult deepCopy() {
    return new MultiScanResult(this);
  }

  @Override
  public void clear() {
    this.results = null;
    this.failures = null;
    this.fullScans = null;
    this.partScan = null;
    this.partNextKey = null;
    setPartNextKeyInclusiveIsSet(false);
    this.partNextKeyInclusive = false;
    setMoreIsSet(false);
    this.more = false;
  }

  public int getResultsSize() {
    return (this.results == null) ? 0 : this.results.size();
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Iterator<TKeyValue> getResultsIterator() {
    return (this.results == null) ? null : this.results.iterator();
  }

  public void addToResults(TKeyValue elem) {
    if (this.results == null) {
      this.results = new java.util.ArrayList<TKeyValue>();
    }
    this.results.add(elem);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.List<TKeyValue> getResults() {
    return this.results;
  }

  public MultiScanResult setResults(@org.apache.thrift.annotation.Nullable java.util.List<TKeyValue> results) {
    this.results = results;
    return this;
  }

  public void unsetResults() {
    this.results = null;
  }

  /** Returns true if field results is set (has been assigned a value) and false otherwise */
  public boolean isSetResults() {
    return this.results != null;
  }

  public void setResultsIsSet(boolean value) {
    if (!value) {
      this.results = null;
    }
  }

  public int getFailuresSize() {
    return (this.failures == null) ? 0 : this.failures.size();
  }

  public void putToFailures(TKeyExtent key, java.util.List<TRange> val) {
    if (this.failures == null) {
      this.failures = new java.util.HashMap<TKeyExtent,java.util.List<TRange>>();
    }
    this.failures.put(key, val);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Map<TKeyExtent,java.util.List<TRange>> getFailures() {
    return this.failures;
  }

  public MultiScanResult setFailures(@org.apache.thrift.annotation.Nullable java.util.Map<TKeyExtent,java.util.List<TRange>> failures) {
    this.failures = failures;
    return this;
  }

  public void unsetFailures() {
    this.failures = null;
  }

  /** Returns true if field failures is set (has been assigned a value) and false otherwise */
  public boolean isSetFailures() {
    return this.failures != null;
  }

  public void setFailuresIsSet(boolean value) {
    if (!value) {
      this.failures = null;
    }
  }

  public int getFullScansSize() {
    return (this.fullScans == null) ? 0 : this.fullScans.size();
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Iterator<TKeyExtent> getFullScansIterator() {
    return (this.fullScans == null) ? null : this.fullScans.iterator();
  }

  public void addToFullScans(TKeyExtent elem) {
    if (this.fullScans == null) {
      this.fullScans = new java.util.ArrayList<TKeyExtent>();
    }
    this.fullScans.add(elem);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.List<TKeyExtent> getFullScans() {
    return this.fullScans;
  }

  public MultiScanResult setFullScans(@org.apache.thrift.annotation.Nullable java.util.List<TKeyExtent> fullScans) {
    this.fullScans = fullScans;
    return this;
  }

  public void unsetFullScans() {
    this.fullScans = null;
  }

  /** Returns true if field fullScans is set (has been assigned a value) and false otherwise */
  public boolean isSetFullScans() {
    return this.fullScans != null;
  }

  public void setFullScansIsSet(boolean value) {
    if (!value) {
      this.fullScans = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public TKeyExtent getPartScan() {
    return this.partScan;
  }

  public MultiScanResult setPartScan(@org.apache.thrift.annotation.Nullable TKeyExtent partScan) {
    this.partScan = partScan;
    return this;
  }

  public void unsetPartScan() {
    this.partScan = null;
  }

  /** Returns true if field partScan is set (has been assigned a value) and false otherwise */
  public boolean isSetPartScan() {
    return this.partScan != null;
  }

  public void setPartScanIsSet(boolean value) {
    if (!value) {
      this.partScan = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public TKey getPartNextKey() {
    return this.partNextKey;
  }

  public MultiScanResult setPartNextKey(@org.apache.thrift.annotation.Nullable TKey partNextKey) {
    this.partNextKey = partNextKey;
    return this;
  }

  public void unsetPartNextKey() {
    this.partNextKey = null;
  }

  /** Returns true if field partNextKey is set (has been assigned a value) and false otherwise */
  public boolean isSetPartNextKey() {
    return this.partNextKey != null;
  }

  public void setPartNextKeyIsSet(boolean value) {
    if (!value) {
      this.partNextKey = null;
    }
  }

  public boolean isPartNextKeyInclusive() {
    return this.partNextKeyInclusive;
  }

  public MultiScanResult setPartNextKeyInclusive(boolean partNextKeyInclusive) {
    this.partNextKeyInclusive = partNextKeyInclusive;
    setPartNextKeyInclusiveIsSet(true);
    return this;
  }

  public void unsetPartNextKeyInclusive() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __PARTNEXTKEYINCLUSIVE_ISSET_ID);
  }

  /** Returns true if field partNextKeyInclusive is set (has been assigned a value) and false otherwise */
  public boolean isSetPartNextKeyInclusive() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __PARTNEXTKEYINCLUSIVE_ISSET_ID);
  }

  public void setPartNextKeyInclusiveIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __PARTNEXTKEYINCLUSIVE_ISSET_ID, value);
  }

  public boolean isMore() {
    return this.more;
  }

  public MultiScanResult setMore(boolean more) {
    this.more = more;
    setMoreIsSet(true);
    return this;
  }

  public void unsetMore() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __MORE_ISSET_ID);
  }

  /** Returns true if field more is set (has been assigned a value) and false otherwise */
  public boolean isSetMore() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __MORE_ISSET_ID);
  }

  public void setMoreIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __MORE_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case RESULTS:
      if (value == null) {
        unsetResults();
      } else {
        setResults((java.util.List<TKeyValue>)value);
      }
      break;

    case FAILURES:
      if (value == null) {
        unsetFailures();
      } else {
        setFailures((java.util.Map<TKeyExtent,java.util.List<TRange>>)value);
      }
      break;

    case FULL_SCANS:
      if (value == null) {
        unsetFullScans();
      } else {
        setFullScans((java.util.List<TKeyExtent>)value);
      }
      break;

    case PART_SCAN:
      if (value == null) {
        unsetPartScan();
      } else {
        setPartScan((TKeyExtent)value);
      }
      break;

    case PART_NEXT_KEY:
      if (value == null) {
        unsetPartNextKey();
      } else {
        setPartNextKey((TKey)value);
      }
      break;

    case PART_NEXT_KEY_INCLUSIVE:
      if (value == null) {
        unsetPartNextKeyInclusive();
      } else {
        setPartNextKeyInclusive((java.lang.Boolean)value);
      }
      break;

    case MORE:
      if (value == null) {
        unsetMore();
      } else {
        setMore((java.lang.Boolean)value);
      }
      break;

    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
    case RESULTS:
      return getResults();

    case FAILURES:
      return getFailures();

    case FULL_SCANS:
      return getFullScans();

    case PART_SCAN:
      return getPartScan();

    case PART_NEXT_KEY:
      return getPartNextKey();

    case PART_NEXT_KEY_INCLUSIVE:
      return isPartNextKeyInclusive();

    case MORE:
      return isMore();

    }
    throw new java.lang.IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new java.lang.IllegalArgumentException();
    }

    switch (field) {
    case RESULTS:
      return isSetResults();
    case FAILURES:
      return isSetFailures();
    case FULL_SCANS:
      return isSetFullScans();
    case PART_SCAN:
      return isSetPartScan();
    case PART_NEXT_KEY:
      return isSetPartNextKey();
    case PART_NEXT_KEY_INCLUSIVE:
      return isSetPartNextKeyInclusive();
    case MORE:
      return isSetMore();
    }
    throw new java.lang.IllegalStateException();
  }

  @Override
  public boolean equals(java.lang.Object that) {
    if (that instanceof MultiScanResult)
      return this.equals((MultiScanResult)that);
    return false;
  }

  public boolean equals(MultiScanResult that) {
    if (that == null)
      return false;
    if (this == that)
      return true;

    boolean this_present_results = true && this.isSetResults();
    boolean that_present_results = true && that.isSetResults();
    if (this_present_results || that_present_results) {
      if (!(this_present_results && that_present_results))
        return false;
      if (!this.results.equals(that.results))
        return false;
    }

    boolean this_present_failures = true && this.isSetFailures();
    boolean that_present_failures = true && that.isSetFailures();
    if (this_present_failures || that_present_failures) {
      if (!(this_present_failures && that_present_failures))
        return false;
      if (!this.failures.equals(that.failures))
        return false;
    }

    boolean this_present_fullScans = true && this.isSetFullScans();
    boolean that_present_fullScans = true && that.isSetFullScans();
    if (this_present_fullScans || that_present_fullScans) {
      if (!(this_present_fullScans && that_present_fullScans))
        return false;
      if (!this.fullScans.equals(that.fullScans))
        return false;
    }

    boolean this_present_partScan = true && this.isSetPartScan();
    boolean that_present_partScan = true && that.isSetPartScan();
    if (this_present_partScan || that_present_partScan) {
      if (!(this_present_partScan && that_present_partScan))
        return false;
      if (!this.partScan.equals(that.partScan))
        return false;
    }

    boolean this_present_partNextKey = true && this.isSetPartNextKey();
    boolean that_present_partNextKey = true && that.isSetPartNextKey();
    if (this_present_partNextKey || that_present_partNextKey) {
      if (!(this_present_partNextKey && that_present_partNextKey))
        return false;
      if (!this.partNextKey.equals(that.partNextKey))
        return false;
    }

    boolean this_present_partNextKeyInclusive = true;
    boolean that_present_partNextKeyInclusive = true;
    if (this_present_partNextKeyInclusive || that_present_partNextKeyInclusive) {
      if (!(this_present_partNextKeyInclusive && that_present_partNextKeyInclusive))
        return false;
      if (this.partNextKeyInclusive != that.partNextKeyInclusive)
        return false;
    }

    boolean this_present_more = true;
    boolean that_present_more = true;
    if (this_present_more || that_present_more) {
      if (!(this_present_more && that_present_more))
        return false;
      if (this.more != that.more)
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int hashCode = 1;

    hashCode = hashCode * 8191 + ((isSetResults()) ? 131071 : 524287);
    if (isSetResults())
      hashCode = hashCode * 8191 + results.hashCode();

    hashCode = hashCode * 8191 + ((isSetFailures()) ? 131071 : 524287);
    if (isSetFailures())
      hashCode = hashCode * 8191 + failures.hashCode();

    hashCode = hashCode * 8191 + ((isSetFullScans()) ? 131071 : 524287);
    if (isSetFullScans())
      hashCode = hashCode * 8191 + fullScans.hashCode();

    hashCode = hashCode * 8191 + ((isSetPartScan()) ? 131071 : 524287);
    if (isSetPartScan())
      hashCode = hashCode * 8191 + partScan.hashCode();

    hashCode = hashCode * 8191 + ((isSetPartNextKey()) ? 131071 : 524287);
    if (isSetPartNextKey())
      hashCode = hashCode * 8191 + partNextKey.hashCode();

    hashCode = hashCode * 8191 + ((partNextKeyInclusive) ? 131071 : 524287);

    hashCode = hashCode * 8191 + ((more) ? 131071 : 524287);

    return hashCode;
  }

  @Override
  public int compareTo(MultiScanResult other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetResults(), other.isSetResults());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetResults()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.results, other.results);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetFailures(), other.isSetFailures());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFailures()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.failures, other.failures);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetFullScans(), other.isSetFullScans());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFullScans()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fullScans, other.fullScans);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetPartScan(), other.isSetPartScan());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPartScan()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.partScan, other.partScan);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetPartNextKey(), other.isSetPartNextKey());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPartNextKey()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.partNextKey, other.partNextKey);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetPartNextKeyInclusive(), other.isSetPartNextKeyInclusive());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPartNextKeyInclusive()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.partNextKeyInclusive, other.partNextKeyInclusive);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetMore(), other.isSetMore());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMore()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.more, other.more);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  @org.apache.thrift.annotation.Nullable
  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    scheme(iprot).read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    scheme(oprot).write(oprot, this);
  }

  @Override
  public java.lang.String toString() {
    java.lang.StringBuilder sb = new java.lang.StringBuilder("MultiScanResult(");
    boolean first = true;

    sb.append("results:");
    if (this.results == null) {
      sb.append("null");
    } else {
      sb.append(this.results);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("failures:");
    if (this.failures == null) {
      sb.append("null");
    } else {
      sb.append(this.failures);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("fullScans:");
    if (this.fullScans == null) {
      sb.append("null");
    } else {
      sb.append(this.fullScans);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("partScan:");
    if (this.partScan == null) {
      sb.append("null");
    } else {
      sb.append(this.partScan);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("partNextKey:");
    if (this.partNextKey == null) {
      sb.append("null");
    } else {
      sb.append(this.partNextKey);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("partNextKeyInclusive:");
    sb.append(this.partNextKeyInclusive);
    first = false;
    if (!first) sb.append(", ");
    sb.append("more:");
    sb.append(this.more);
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // check for sub-struct validity
    if (partScan != null) {
      partScan.validate();
    }
    if (partNextKey != null) {
      partNextKey.validate();
    }
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
    try {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
      __isset_bitfield = 0;
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class MultiScanResultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public MultiScanResultStandardScheme getScheme() {
      return new MultiScanResultStandardScheme();
    }
  }

  private static class MultiScanResultStandardScheme extends org.apache.thrift.scheme.StandardScheme<MultiScanResult> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, MultiScanResult struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
          break;
        }
        switch (schemeField.id) {
          case 1: // RESULTS
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list24 = iprot.readListBegin();
                struct.results = new java.util.ArrayList<TKeyValue>(_list24.size);
                @org.apache.thrift.annotation.Nullable TKeyValue _elem25;
                for (int _i26 = 0; _i26 < _list24.size; ++_i26)
                {
                  _elem25 = new TKeyValue();
                  _elem25.read(iprot);
                  struct.results.add(_elem25);
                }
                iprot.readListEnd();
              }
              struct.setResultsIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // FAILURES
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map27 = iprot.readMapBegin();
                struct.failures = new java.util.HashMap<TKeyExtent,java.util.List<TRange>>(2*_map27.size);
                @org.apache.thrift.annotation.Nullable TKeyExtent _key28;
                @org.apache.thrift.annotation.Nullable java.util.List<TRange> _val29;
                for (int _i30 = 0; _i30 < _map27.size; ++_i30)
                {
                  _key28 = new TKeyExtent();
                  _key28.read(iprot);
                  {
                    org.apache.thrift.protocol.TList _list31 = iprot.readListBegin();
                    _val29 = new java.util.ArrayList<TRange>(_list31.size);
                    @org.apache.thrift.annotation.Nullable TRange _elem32;
                    for (int _i33 = 0; _i33 < _list31.size; ++_i33)
                    {
                      _elem32 = new TRange();
                      _elem32.read(iprot);
                      _val29.add(_elem32);
                    }
                    iprot.readListEnd();
                  }
                  struct.failures.put(_key28, _val29);
                }
                iprot.readMapEnd();
              }
              struct.setFailuresIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // FULL_SCANS
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list34 = iprot.readListBegin();
                struct.fullScans = new java.util.ArrayList<TKeyExtent>(_list34.size);
                @org.apache.thrift.annotation.Nullable TKeyExtent _elem35;
                for (int _i36 = 0; _i36 < _list34.size; ++_i36)
                {
                  _elem35 = new TKeyExtent();
                  _elem35.read(iprot);
                  struct.fullScans.add(_elem35);
                }
                iprot.readListEnd();
              }
              struct.setFullScansIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // PART_SCAN
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.partScan = new TKeyExtent();
              struct.partScan.read(iprot);
              struct.setPartScanIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // PART_NEXT_KEY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.partNextKey = new TKey();
              struct.partNextKey.read(iprot);
              struct.setPartNextKeyIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // PART_NEXT_KEY_INCLUSIVE
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.partNextKeyInclusive = iprot.readBool();
              struct.setPartNextKeyInclusiveIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // MORE
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.more = iprot.readBool();
              struct.setMoreIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

      // check for required fields of primitive type, which can't be checked in the validate method
      struct.validate();
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot, MultiScanResult struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.results != null) {
        oprot.writeFieldBegin(RESULTS_FIELD_DESC);
        {
          oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.results.size()));
          for (TKeyValue _iter37 : struct.results)
          {
            _iter37.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
      if (struct.failures != null) {
        oprot.writeFieldBegin(FAILURES_FIELD_DESC);
        {
          oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.LIST, struct.failures.size()));
          for (java.util.Map.Entry<TKeyExtent, java.util.List<TRange>> _iter38 : struct.failures.entrySet())
          {
            _iter38.getKey().write(oprot);
            {
              oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, _iter38.getValue().size()));
              for (TRange _iter39 : _iter38.getValue())
              {
                _iter39.write(oprot);
              }
              oprot.writeListEnd();
            }
          }
          oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
      }
      if (struct.fullScans != null) {
        oprot.writeFieldBegin(FULL_SCANS_FIELD_DESC);
        {
          oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.fullScans.size()));
          for (TKeyExtent _iter40 : struct.fullScans)
          {
            _iter40.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
      if (struct.partScan != null) {
        oprot.writeFieldBegin(PART_SCAN_FIELD_DESC);
        struct.partScan.write(oprot);
        oprot.writeFieldEnd();
      }
      if (struct.partNextKey != null) {
        oprot.writeFieldBegin(PART_NEXT_KEY_FIELD_DESC);
        struct.partNextKey.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(PART_NEXT_KEY_INCLUSIVE_FIELD_DESC);
      oprot.writeBool(struct.partNextKeyInclusive);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(MORE_FIELD_DESC);
      oprot.writeBool(struct.more);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class MultiScanResultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public MultiScanResultTupleScheme getScheme() {
      return new MultiScanResultTupleScheme();
    }
  }

  private static class MultiScanResultTupleScheme extends org.apache.thrift.scheme.TupleScheme<MultiScanResult> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, MultiScanResult struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet optionals = new java.util.BitSet();
      if (struct.isSetResults()) {
        optionals.set(0);
      }
      if (struct.isSetFailures()) {
        optionals.set(1);
      }
      if (struct.isSetFullScans()) {
        optionals.set(2);
      }
      if (struct.isSetPartScan()) {
        optionals.set(3);
      }
      if (struct.isSetPartNextKey()) {
        optionals.set(4);
      }
      if (struct.isSetPartNextKeyInclusive()) {
        optionals.set(5);
      }
      if (struct.isSetMore()) {
        optionals.set(6);
      }
      oprot.writeBitSet(optionals, 7);
      if (struct.isSetResults()) {
        {
          oprot.writeI32(struct.results.size());
          for (TKeyValue _iter41 : struct.results)
          {
            _iter41.write(oprot);
          }
        }
      }
      if (struct.isSetFailures()) {
        {
          oprot.writeI32(struct.failures.size());
          for (java.util.Map.Entry<TKeyExtent, java.util.List<TRange>> _iter42 : struct.failures.entrySet())
          {
            _iter42.getKey().write(oprot);
            {
              oprot.writeI32(_iter42.getValue().size());
              for (TRange _iter43 : _iter42.getValue())
              {
                _iter43.write(oprot);
              }
            }
          }
        }
      }
      if (struct.isSetFullScans()) {
        {
          oprot.writeI32(struct.fullScans.size());
          for (TKeyExtent _iter44 : struct.fullScans)
          {
            _iter44.write(oprot);
          }
        }
      }
      if (struct.isSetPartScan()) {
        struct.partScan.write(oprot);
      }
      if (struct.isSetPartNextKey()) {
        struct.partNextKey.write(oprot);
      }
      if (struct.isSetPartNextKeyInclusive()) {
        oprot.writeBool(struct.partNextKeyInclusive);
      }
      if (struct.isSetMore()) {
        oprot.writeBool(struct.more);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, MultiScanResult struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(7);
      if (incoming.get(0)) {
        {
          org.apache.thrift.protocol.TList _list45 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT);
          struct.results = new java.util.ArrayList<TKeyValue>(_list45.size);
          @org.apache.thrift.annotation.Nullable TKeyValue _elem46;
          for (int _i47 = 0; _i47 < _list45.size; ++_i47)
          {
            _elem46 = new TKeyValue();
            _elem46.read(iprot);
            struct.results.add(_elem46);
          }
        }
        struct.setResultsIsSet(true);
      }
      if (incoming.get(1)) {
        {
          org.apache.thrift.protocol.TMap _map48 = iprot.readMapBegin(org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.LIST); 
          struct.failures = new java.util.HashMap<TKeyExtent,java.util.List<TRange>>(2*_map48.size);
          @org.apache.thrift.annotation.Nullable TKeyExtent _key49;
          @org.apache.thrift.annotation.Nullable java.util.List<TRange> _val50;
          for (int _i51 = 0; _i51 < _map48.size; ++_i51)
          {
            _key49 = new TKeyExtent();
            _key49.read(iprot);
            {
              org.apache.thrift.protocol.TList _list52 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT);
              _val50 = new java.util.ArrayList<TRange>(_list52.size);
              @org.apache.thrift.annotation.Nullable TRange _elem53;
              for (int _i54 = 0; _i54 < _list52.size; ++_i54)
              {
                _elem53 = new TRange();
                _elem53.read(iprot);
                _val50.add(_elem53);
              }
            }
            struct.failures.put(_key49, _val50);
          }
        }
        struct.setFailuresIsSet(true);
      }
      if (incoming.get(2)) {
        {
          org.apache.thrift.protocol.TList _list55 = iprot.readListBegin(org.apache.thrift.protocol.TType.STRUCT);
          struct.fullScans = new java.util.ArrayList<TKeyExtent>(_list55.size);
          @org.apache.thrift.annotation.Nullable TKeyExtent _elem56;
          for (int _i57 = 0; _i57 < _list55.size; ++_i57)
          {
            _elem56 = new TKeyExtent();
            _elem56.read(iprot);
            struct.fullScans.add(_elem56);
          }
        }
        struct.setFullScansIsSet(true);
      }
      if (incoming.get(3)) {
        struct.partScan = new TKeyExtent();
        struct.partScan.read(iprot);
        struct.setPartScanIsSet(true);
      }
      if (incoming.get(4)) {
        struct.partNextKey = new TKey();
        struct.partNextKey.read(iprot);
        struct.setPartNextKeyIsSet(true);
      }
      if (incoming.get(5)) {
        struct.partNextKeyInclusive = iprot.readBool();
        struct.setPartNextKeyInclusiveIsSet(true);
      }
      if (incoming.get(6)) {
        struct.more = iprot.readBool();
        struct.setMoreIsSet(true);
      }
    }
  }

  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
  }
  private static void unusedMethod() {}
}

